﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ControlBaoCaoXuatNhapTon.ascx.cs" Inherits="UserControl_ControlBaoCaoXuatNhapTon" %>

<%@ Register assembly="DevExpress.Web.ASPxEditors.v9.2, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>

<%@ Register assembly="DevExpress.Web.ASPxPivotGrid.v9.2, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPivotGrid" tagprefix="dxwpg" %>
<%@ Register assembly="DevExpress.Web.ASPxPivotGrid.v9.2.Export, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.XtraPivotGrid.Web" tagprefix="dxpgw" %>



<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<script type="text/javascript">
    function pageLoad() {

        //Ngày
        $(function () {
            $("#<%= txtFromDate.ClientID %>").datePicker(
	                {
	                    clickInput: true,
	                    startDate: '01/01/1970'
	                }
	                );
        });

        $("#<%= txtFromDate.ClientID %>").bind(
		            'dpClosed', function (e, selectedDates) {
		                var d = selectedDates[0];
		                if (d) {
		                    d = new Date(d);
		                    $("#<%= txtToDate.ClientID %>").dpSetStartDate(d.addDays(0).asString());
		                }
		            }
	                    );

        $(function () {
            $("#<%= txtToDate.ClientID %>").datePicker(
	                {
	                    clickInput: true

	                }
	                );
        });

        $("#<%= txtToDate.ClientID %>").bind(
		           'dpClosed', function (e, selectedDates) {
		               var d = selectedDates[0];
		               if (d) {
		                   d = new Date(d);
		                   $("#<%= txtFromDate.ClientID %>").dpSetEndDate(d.addDays(0).asString());
		               }
		           }
	            );

        $("#<%= imgBtnAdd.ClientID %>").click(function () {
            if ($("#<%= txtFromDate.ClientID %>").val().length > 0 && $("#<%= txtToDate.ClientID %>").val().length > 0) {
                $.blockUI({
                    message: '<h1>Xin vui lòng chờ xử lý</h1>',
                    css: {
                        border: 'none',
                        padding: '15px',
                        backgroundColor: '#f00',
                        opacity: .5,
                        color: '#fff'
                    }
                });
            }
        });
        $("#<%= imgBtnSave.ClientID %>").click(function () {
            $.blockUI({
                message: '<h1>Xin vui lòng chờ xử lý</h1>',
                css: {
                    border: 'none',
                    padding: '15px',
                    backgroundColor: '#f00',
                    opacity: .5,
                    color: '#fff'
                }
            });
            setTimeout($.unblockUI, 5000);
        });


        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        function EndRequestHandler(sender, args) {
            $.unblockUI();
        }

    }

</script>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="imgBtnSave" />
</Triggers>

    <ContentTemplate>
     <div class="direct_container_right_titletop">
                     Báo cáo xuất nhập tồn
                </div>
                 <hr />
                <!-- Button chuc nang-->
                <div class="direct_container_main">
                    <table>
                        <tr>
                            <td>Từ ngày</td>
                            <td>  
                                <asp:TextBox ID="txtFromDate" runat="server"></asp:TextBox> 
                                 <asp:RequiredFieldValidator ControlToValidate="txtFromDate" Display="None"  ID="RFVName" runat="server" ErrorMessage="Phải chọn ngày">
                                </asp:RequiredFieldValidator>
                                <cc1:ValidatorCalloutExtender TargetControlID="RFVName" ID="ValidatorCalloutExtender1" runat="server">
                                </cc1:ValidatorCalloutExtender>                                
                            </td>
                            <td>Đến Ngày</td>
                            <td>
                                <asp:TextBox ID="txtToDate" runat="server"></asp:TextBox> 
                                 <asp:RequiredFieldValidator ControlToValidate="txtToDate" Display="None"  ID="RequiredFieldValidator1" runat="server" ErrorMessage="Phải chọn ngày">
                                </asp:RequiredFieldValidator>
                                <cc1:ValidatorCalloutExtender TargetControlID="RequiredFieldValidator1" ID="ValidatorCalloutExtender2" runat="server">
                                </cc1:ValidatorCalloutExtender> 
                            </td>
                            <td>
                                  <asp:ImageButton ID="imgBtnAdd" ToolTip="Lấy dữ liệu" onclick="imgBtnAdd_Click"  ImageUrl="~/Images/Document.png" Width="32px" Height="32px" runat="server" />
                                  <asp:ImageButton ID="imgBtnSave" ToolTip="Xuất ra file excel" CausesValidation="false" onclick="imgBtnSave_Click" ImageUrl="~/Images/download.png" Width="32px" Height="32px" runat="server" />
                    
                            </td>
                        </tr>
                    </table>                   
                    
                </div>
                <!-- End Button chuc nang-->
    <div style="overflow:scroll; width:100%">
        <dxpgw:ASPxPivotGridExporter ID="ASPxPivotGridExporter1" ASPxPivotGridID="ASPxPivotGrid1" runat="server" Width="100%">
        </dxpgw:ASPxPivotGridExporter>
        <dxwpg:ASPxPivotGrid ID="ASPxPivotGrid1" runat="server">
                 <Fields>
                <dxwpg:PivotGridField ID="PivotGridField1" Area="RowArea"  AreaIndex="0" 
                         Caption="Cửa hàng" FieldName="Cửa hàng">
                </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="PivotGridField3" Area="RowArea"  AreaIndex="1" 
                         Caption="Ngành hàng" FieldName="Ngành hàng">
                </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="PivotGridField4" Area="RowArea"  AreaIndex="2" 
                         Caption="Nhản hiệu" FieldName="Nhản hiệu">
                </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="PivotGridField5" Area="RowArea"  AreaIndex="3" 
                         Caption="Sản phẩm" FieldName="Sản phẩm">
                </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="PivotGridField6" Area="RowArea"  AreaIndex="4" 
                         Caption="Mã hàng" FieldName="Mã hàng">
                </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="PivotGridField7" Area="RowArea"  AreaIndex="5" 
                         Caption="Tên hàng" FieldName="Tên hàng">
                </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="PivotGridField8" Area="DataArea"  AreaIndex="2" 
                         Caption="Tồn đầu" FieldName="Tồn đầu">
                </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="PivotGridField9" Area="DataArea"  AreaIndex="3" 
                         Caption="Giá vốn tồn đầu" FieldName="Giá vốn tồn đầu">
                </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldBn" Area="DataArea" AreaIndex="4" 
                         Caption="Bán" FieldName="Bán">
                     </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldGivnhngbn" Area="DataArea" AreaIndex="1" 
                         Caption="Giá vốn hàng bán" FieldName="Giá vốn hàng bán">
                     </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldDoanhs" Area="DataArea" AreaIndex="0" 
                         Caption="Doanh số" FieldName="Doanh số">
                     </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldChuynchochinhnhkhc" Area="DataArea" 
                         AreaIndex="5" Caption="Chuyển cho chi nhánh khác" 
                         FieldName="Chuyển cho chi nhánh khác">
                     </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldGivnhngchuyn" Area="DataArea" AreaIndex="6" 
                         Caption="Giá vốn hàng chuyển" FieldName="Giá vốn hàng chuyển">
                     </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldTrhngvNCC" Area="DataArea" AreaIndex="7" 
                         Caption="Trả hàng về NCC" FieldName="Trả hàng về NCC">
                     </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldGivnhngtrNCC" Area="DataArea" AreaIndex="8" 
                         Caption="Giá vốn hàng trả NCC" FieldName="Giá vốn hàng trả NCC">
                     </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldKhuynmi" Area="DataArea" AreaIndex="9" 
                         Caption="Khuyến mãi" FieldName="Khuyến mãi">
                     </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="fieldGivnKM" Area="DataArea"  AreaIndex="10" 
                         Caption="Giá vốn KM" FieldName="Giá vốn KM">
                </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="fieldNhphng" Area="DataArea"  AreaIndex="11" 
                         Caption="Nhập hàng" FieldName="Nhập hàng">
                </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="fieldTinnhphng" Area="DataArea"  AreaIndex="12" 
                         Caption="Tiền nhập hàng" FieldName="Tiền nhập hàng">
                </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="fieldKhchtrhng" Area="DataArea"  AreaIndex="13" 
                         Caption="Khách trả hàng" FieldName="Khách trả hàng">
                </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="fieldTinhngtr" Area="DataArea"  AreaIndex="14" 
                         Caption="Tiền hàng trả" FieldName="Tiền hàng trả">
                </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldNhntchinhnhkhc" Area="DataArea" AreaIndex="15" 
                         Caption="Nhận từ chi nhánh khác" FieldName="Nhận từ chi nhánh khác">
                     </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldGivnhngnhn" Area="DataArea" AreaIndex="16" 
                         Caption="Giá vốn hàng nhận" FieldName="Giá vốn hàng nhận">
                     </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldcKM" Area="DataArea" AreaIndex="17" 
                         Caption="Được KM" FieldName="Được KM">
                     </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldGitrKM" Area="DataArea" AreaIndex="18" 
                         Caption="Giá trị KM" FieldName="Giá trị KM">
                     </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldTncui" Area="DataArea" AreaIndex="19" 
                         Caption="Tồn cuối" FieldName="Tồn cuối">
                     </dxwpg:PivotGridField>
                     <dxwpg:PivotGridField ID="fieldGivntncui" Area="DataArea" AreaIndex="20" 
                         Caption="Giá vốn tồn cuối" FieldName="Giá vốn tồn cuối">
                     </dxwpg:PivotGridField>
                </Fields>
        </dxwpg:ASPxPivotGrid>
    </div>
    </ContentTemplate>
</asp:UpdatePanel>